The US 2007/0098139 A1 discloses a method and a system for an energy-resolved counting of X-ray photons. The system comprises a charge amplifier in which charge signals corresponding to detected photons are amplified, a signal shaper in which pulses corresponding to the charge signals are generated, an energy level discriminator in which said pulses are discriminated with respect to photon energy, and a counter for counting the number of detected and discriminated pulses. Moreover, the system comprises a controller that receives the output of the counter and that adjusts the shaping time of the signal shaper based on this photon count feedback.